package demo.homework;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import static demo.until.FileUtil.FILE_PATH;

public class Demo1 {

    /**
     * 使用IO流实现文件拷贝
     *
     * @param args
     * @throws IOException
     */


    public static void main(String[] args) throws IOException {
        String fromPath = "E:\\fileDemo.mp4";

        String toPath = FILE_PATH + "test.mp4";

        FileInputStream fis = new FileInputStream(fromPath);

        FileOutputStream fos = new FileOutputStream(toPath);

        int c;

        /**
         * 很慢原因是：一次只读取一个字节
         */

        while ((c = fis.read()) != -1) {
            fos.write(c);
        }
    }
}
